<?php

/**
 * @author @author Samrat Khan & Sadik Sarfaraz - May 19, 2013
 */
require 'top.inc.php';
$formLoad = new Form();
if(isset($_SESSION['user']) && $_SESSION['user']['utype'] == 1 || $_SESSION['user']['utype'] == 2 || $_SESSION['user']['utype'] == 3 || $_SESSION['user']['utype'] == 4) {
    $sess_cusID = $_SESSION['user']['cus_id'];
?>
<h5>Faulty Return Entry</h5>
<form name="addFaulty" id="addFaulty" method="post">
<?php
echo "<table class=\"form-inline row-fluid table table-striped table-bordered\">";
    echo "<tr>";
        echo "<th>" . $faulties['serialno'] . "</th>";
        echo "<th>" . $faulties['project_id'] . "</th>";
        echo "<th>" . $faulties['rma'] . "</th>";
        echo "<th>" . $faulties['pickuprequestdate'] . "</th>";
        echo "<th>" . $faulties['physicallyreceivedate'] . "</th>";
        echo "<th>" . $faulties['productid'] . "</th>";
        echo "<th>" . $faulties['description'] . "</th>";
        echo "<th>" . $faulties['revisionstate'] . "</th>";
        echo "<th>" . $faulties['boxno'] . "</th>";
        echo "<th>" . $faulties['return_quantity'] . "</th>";
        echo "<th>" . $faulties['uom'] . "</th>";
        echo "<th>" . $faulties['manufacturingdate'] . "</th>";
        echo "<th>" . $faulties['faultiesstatus'] . "</th>";
        echo "<th>" . $faulties['siteid'] . "</th>";
        echo "<th>" . $faulties['warehouseid'] . "</th>";
        echo "<th>" . $faulties['employeeid'] . "</th>";
		echo "<th>" . $stock_out['eng_id'] . "</th>";
        //echo "<th>" . $faulties['receivedfrom'] . "</th>";
        echo "<th>" . $faulties['docketdate'] . "</th>";
        echo "<th>" . $faulties['faulties_docketnumber'] . "</th>";
        echo "<th>" . $faulties['remarks'] . "</th>";
        echo "<th>" . "&nbsp;" . "</th>";
    echo "</tr>";
    
    echo "<tr>";
        echo "<td>" . $formLoad->textField("serialno", "", "faulty_in_sn", $faulties['serialno']) . "</td>";
        echo "<td>";
            echo "<select name='project_id'>";
                echo getProjects(cus_id, $sess_cusID, $db);
            echo "</select>";
        echo "</td>";
        echo "<td>" . $formLoad->textField("rma", "", "rma", $faulties['rma']) . "</td>";
        echo "<td>" . $formLoad->textFieldDate("pickuprequestdate", "input-append date", "pickuprequestdate", $faulties['pickuprequestdate']) . "</td>";
        echo "<td>" . $formLoad->textFieldDate("physicallyreceivedate", "input-append date", "physicallyreceivedate", $faulties['physicallyreceivedate']) . "</td>";
        echo "<td>" . $formLoad->textField("productid", "productid", "productid", $faulties['productid']) . "</td>";
        echo "<td>" . $formLoad->textField('description', "", "description", $faulties['description']) . "</td>";
        //echo "<td>" . $formLoad->textArea("description", "description", "description") . "</td>";
        echo "<td>" . $formLoad->textField("revisionstate", "revisionstate", "revisionstate", $faulties['revisionstate']) . "</td>";
        echo "<td>" . $formLoad->textField("boxno", "boxno", "boxno", $faulties['boxno'], "NULL") . "</td>";
        echo "<td>" . $formLoad->textField("return_quantity", "return_quantity", "return_quantity", $faulties['return_quantity'], 1) . "</td>";
        echo "<td>";
            echo "<select name='uom' id='uom'>";
                echo getUOM($db);
            echo "</select>";
        echo "</td>";
        echo "<td>" . $formLoad->textField("manufacturingdate", "manufacturingdate", "manufacturingdate", $faulties['manufacturingdate']) . "</td>";
        echo "<td>";
            echo "<select name='faultiesstatus'>";
                echo getReturningStatus($db);
            echo "</select>";
        echo "</td>";
        echo "<td>" . $formLoad->textField("siteid", "siteid", "siteid", $faulties['siteid']) . "</td>";
        echo "<td>";
            echo "<select name='warehouseid'>";
                echo "<option value='' selected>". "Select..." ."</option>";
                echo getWarehousesCode($db);
            echo "</select>";
        echo "</td>";
        echo "<td>";
            echo "<select name='employeeid'>";
                echo "<option value='' selected>". "Select..." ."</option>";
                echo getEmployees($db);
            echo "</select>";
        echo "</td>";
		echo "<td>";
            echo "<select name='receivedfrom' id='eng_id'>";
                echo "<option value='' selected>". "Select..." ."</option>";
                echo getEngineers($db);
            echo "</select>";
        echo "</td>";
        //echo "<td>" . $formLoad->textField("receivedfrom", "receivedfrom", "receivedfrom", $faulties['receivedfrom']) . "</td>";
        echo "<td>" . $formLoad->textFieldDate("docketdate", "input-append date", "docketdate", $faulties['docketdate']) . "</td>";
        echo "<td>" . $formLoad->textField("faulties_docketnumber", "faulties_docketnumber", "", $faulties['faulties_docketnumber']) . "</td>";
        echo "<td>" . $formLoad->textArea("remarks", "", "remarks") . "</td>";
        
        echo '<input type="hidden" name="userid" value="'.$_SESSION['user']['id'].'" />';
        echo '<input type="hidden" name="cus_id" value="'.$_SESSION['user']['cus_id'].'" />';
        echo '<input type="hidden" name="session_id" value="'.  session_id() .'" />';
        echo '<input type="hidden" name="junkentry" value="0" />';
        echo "<td>";
            echo '<input id="AddFaultyBtn" class="btn btn-primary" type="submit" value="Add Faulty" name="addFaulty" />';
        echo "</td>";
    echo "</tr>";
echo "<table>";
?>
</form>

<div id="show"></div>
<?php
}
include 'bottom.inc.php';
?>
